﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Axis.Dao.News;
using Axis.BusinessObject.News;
using Axis.Web.Administrator.Global;
using Axis.Dao.Core;
using Axis.BusinessObject.Core;

namespace Axis.Web.Administrator.Views.News
{
    public partial class NewsList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //<InputValue UserID="1" SecrectToken=”” ID="1" />
            IList<CTag> allCloundTabs = new CNewsDao().GetTags(string.Format("<InputValue UserID='{0}' SecrectToken='{1}' RowsPerPage='2000' PageIndex='1'/>", CSecurity.USER_ID, CSecurity.SECRECT_TOKEN));
            ddlCloundTags.DataSource = allCloundTabs;
            ddlCloundTags.DataTextField = "Text";
            ddlCloundTags.DataValueField = "ID";
            ddlCloundTags.DataBind();
            ddlCloundTags.Items.Insert(0, new ListItem("(Tất cả)", "-100"));

            ddlTags.DataSource = allCloundTabs;
            ddlTags.DataTextField = "Text";
            ddlTags.DataValueField = "ID";
            ddlTags.DataBind();
            ddlTags.Items.Insert(0, new ListItem("(Tất cả)", "-100"));


            IList<CListData> allCate = new CCoreDao().GetListData(string.Format("<InputValue UserID='{0}' SecrectToken='{1}' FunctionCode='MenuCategoryAll'/>", CSecurity.USER_ID, CSecurity.SECRECT_TOKEN));
            string optCate = "";
            foreach (var item in allCate)
            {
                if (item.ParentID > 0)
                    optCate += string.Format("<option value='{0}'>&nbsp;&nbsp;&nbsp;{1}</option>", item.Value, item.Name); 
                else
                    optCate += string.Format("<option value='{0}' style=\"color:red\">{1}</option>", item.Value, item.Name); 
                 
            }
            lblOptionCate.Text=optCate;
            lblOptionCate2.Text=optCate;
            lblProject.Text= (new CNewsUI()).GetProjectName();

        }
    }
}